package helen.core.tools.appmonitor;

import java.lang.Thread.UncaughtExceptionHandler;

/**
 *
 * @author Andun
 * @date 2013-5-17
 */
public class AppException extends Exception implements UncaughtExceptionHandler{

    private static final long serialVersionUID = 1L;

    /** 系统默认的UncaughtException处理类 */
    private UncaughtExceptionHandler mDefaultHandler;

    private AppException(){
        this.mDefaultHandler = Thread.getDefaultUncaughtExceptionHandler();
    }

    /**
     * 获取APP异常崩溃处理对象
     * @param context
     * @return
     */
    public static AppException getAppExceptionHandler(){
        return new AppException();
    }

    @Override
    public void uncaughtException(Thread thread, Throwable ex) {
        if(mDefaultHandler != null) {
//			System.exit(0);
            mDefaultHandler.uncaughtException(thread, ex);
        }
    }
}
